
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>添加子域名扫描任务</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">

    <div class="layui-form-item">
        <label class="layui-form-label required">任务名</label>
        <div class="layui-input-block">
            <input type="text" name="CusName" lay-verify="required" lay-reqtext="任务名不能为空" placeholder="请输入任务名"
                   class="layui-input">
            <tip>若追加已有任务,请填写该任务名;如有多个扫描任务同时运行，则不保证消息队列顺序(消息发送是随机的)</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">主域名</label>
        <div class="layui-input-block">
            <textarea name="Domain" id="Domain" rows=10 class="layui-textarea" placeholder="添加主域名，一行一个"></textarea>
            <tip>请勿添加重复已扫描过的主域名，否则结果将会有重复数据(可删除旧任务创建新任务)</tip>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="SubDomainAdd_form">添加任务</button>
        </div>
    </div>
</div>
<script src="/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function() {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(SubDomainAdd_form)', function(data) {
            $.ajax({
                url: "/api/util/subdomain/add",
                data: JSON.stringify(data.field),
                contentType: 'application/json;charset=UTF-8',
                dataType: 'json',
                type: 'post',
                success: function(result) {
                    if (result.code == 200) {
                        var index = layer.alert("添加子域名扫描任务成功", {
                            title: '提示',
                            icon: 1
                        }, function() {
                            parent.layui.table.reload("currentTable_subdomainmanager");
                            layer.close(index);
                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex);
                        })
                    } else {
                        layer.alert(result.msg, {
                            title: '提示',
                            icon: 2
                        })
                    }
                },
                error: function (e) {
                    layer.alert(JSON.stringify(e), {title: '提示', icon: 2})
                }
            })
            return false;
        });
    });
</script>
</body>
</html>
